package com.cyjt.operation.bean;

import java.io.Serializable;
import java.util.Date;

import com.cyjt.operation.base.Tools;

/**
 * 静态节点列表实体类
 * 
 * @author LTP
 * 
 */
public class NodesStatusInfo implements Serializable {

	private static final long serialVersionUID = 1L;
	/** 基站编码 */
	private String basestationNfcCode;
	/** 车位编码 */
	private String code;
	/** 节点编码 */
	private String sensorCode;
	/** 节点所在路段 */
	private String title;
	/** 节点最新心跳时间 */
	private Date submitAt;
	/** 节点状态 */
	private int status;
	private int state;

	/**
	 * @return 基站编码
	 */
	public String getBasestationNfcCode() {
		return basestationNfcCode;
	}

	public void setBasestationNfcCode(String basestationNfcCode) {
		this.basestationNfcCode = basestationNfcCode;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	/**
	 * @return 车位编码
	 */
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * @return 节点编号
	 */
	public String getSensorCode() {
		return sensorCode;
	}

	public void setSensorCode(String sensorCode) {
		this.sensorCode = sensorCode;
	}

	/**
	 * @return 节点所在路段
	 */
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @return 节点最新心跳时间
	 */
	public Date getSubmitAt() {
		return submitAt;
	}

	/**
	 * @return 节点最新心跳时间
	 */
	public String getSubmitAtString() {
		if (getSubmitAt() == null) {
			return Tools.getDF(new Date()).toString();
		}
		return Tools.getDF(getSubmitAt()).toString();
	}

	/**
	 * 获得最后心跳与目前的间隔时间
	 * 
	 * @return 间隔时间
	 */
	public String getTimeFromNow() {
		if (getSubmitAt() != null) {
			String s = Tools.diffTime(getSubmitAt(), new Date());
			if (s.equals("")) {
				return "刚刚";
			}
			return Tools.diffTime(getSubmitAt(), new Date()) + "前";
		}
		return "无提交时间";
	}

	public void setSubmitAt(Date submitAt) {
		this.submitAt = submitAt;
	}

	public int getStatus() {
		return status;
	}

	/**
	 * 节点状态信息
	 * 
	 * @return 正常或异常
	 */
	public String getStatusToString() {
		if (status == 1) {
			return "正常";
		}
		return "异常";
	}

	public void setStatus(int status) {
		this.status = status;
	}
}
